open Printf
    
(** wiersz x kolumna *)
type position = int * int
type location = | Single of position | Range of position * position

let create_position row col : position = row , col
let back_one_char (row, col) = if col = 0 then (row - 1, col) else (row, col -1)

let start_position = function
  | Single pos -> pos
  | Range (p1, _) -> p1

let end_position = function
  | Single pos -> pos
  | Range (_, p2) -> p2

let sprintf_position (row, col) = sprintf "(%d, %d)" row col
let sprintf_location = function
  |Single pos -> sprintf_position pos
  |Range (p1, p2) -> sprintf "%s-%s" (sprintf_position p1) (sprintf_position p2)
